<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>


<div id="filter">
<s:form  action="saveContacts" method="post" cssClass="tableFilter" theme="simple" >

    <s:hidden name="id" value="%{comiteEtica.id}"/>

    <TABLE id="table_content" width="350px" border="1" class="tableEdit" >
        <TR>
            <th>Role</th>
            <th>Degree</th>
            <th>email</th>
            <th>Fax</th>
        </TR>

        <TR>
            <TD>
                <s:select label="Role" name="comiteEtica.contactPersons[0].role.id" id="role"
    headerKey="-1" headerValue="Choose a Role"
    list="roles"
    listKey="id"
    listValue="descripcion"
    theme="simple">
                </s:select>
            </TD>
            <TD><s:textfield name="comiteEtica.contactPersons[0].degree" theme="simple"/></TD>
            <TD><s:textfield name="comiteEtica.contactPersons[0].email" theme="simple"/></TD>
            <TD><s:textfield name="comiteEtica.contactPersons[0].fax" theme="simple"/></TD>

        </TR>
    </TABLE>
    <INPUT type="button" value="Add More" onclick="addRow('table_content')" />
    <input type="submit" value="SUBMIT"/>
</s:form>
  </div>
<SCRIPT language="javascript">
    function addRow(tableID) {

        var table = document.getElementById(tableID);

        var rowCount = table.rows.length;
        var row = table.insertRow(rowCount);
        var counts=rowCount-1;

        var path = "comiteEtica.contactPersons";

        var cell1 = row.insertCell(0);
        var role = $('#role').clone()[0];
        role.name=path+"["+counts+"].role.id";
        cell1.appendChild(role);

        var cell1 = row.insertCell(1);
        var degree = document.createElement("input");
        degree.type = "text";
        degree.name=path+"["+counts+"].degree";
        cell1.appendChild(degree);

        var cell1 = row.insertCell(2);
        var email = document.createElement("input");
        email.type = "text";
        email.name=path+"["+counts+"].email";
        cell1.appendChild(email);

        var cell1 = row.insertCell(3);
        var fax = document.createElement("input");
        fax.type = "text";
        fax.name=path+"["+counts+"].fax";
        cell1.appendChild(fax);

    }
</SCRIPT>

